// 导入组件
import Vue from 'vue'
import Router from 'vue-router'
import VueRouter from 'vue-router'

// 启用路由
Vue.use(Router)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) {
    return originalPush.call(this, location, onResolve, onReject)
  }
  return originalPush.call(this, location).catch(err => err)
}

// 导出路由
export default new Router({
  routes: [{
    path: '/',
    name: '',
    component: resolve => require(['@/views/login'], resolve),
    hidden: true,
    meta: {
      requireAuth: false
    }
  }, {
    path: '/index',
    name: '',
    component: resolve => require(['@/views/index'], resolve),
    hidden: true,
    meta: {
      requireAuth: false
    }
  }, {
    path: '/login',
    name: '登录',
    component: resolve => require(['@/views/login'], resolve),
    hidden: true,
    meta: {
      requireAuth: false
    }
  }, {
    path: '/index',
    name: '首页',
    component: resolve => require(['@/views/index'], resolve),
    iconCls: 'el-icon-tickets',
    children: [{
      path: '/admin/index',
      name: '',
      component: resolve => require(['@/views/admin/index'], resolve),
      hidden: true,
      meta: {
        requireAuth: false
      }
    }, {
      path: '/goods/Goods',
      name: '商品管理',
      component: resolve => require(['@/views/goods/Goods'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/permission/menu',
      name: '菜单管理1',
      component: resolve => require(['@/views/system/MenuManager'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/machine/Machine',
      name: '机器信息管理',
      component: resolve => require(['@/views/machine/MachineAisle'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/machine/MachineAisle',
      name: '货道信息管理',
      component: resolve => require(['@/views/machine/MachineAisle'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/pay/Order',
      name: '交易订单',
      component: resolve => require(['@/views/pay/Order'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/system/user',
      name: '用户管理',
      component: resolve => require(['@/views/system/user'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/system/Module',
      name: '菜单管理',
      component: resolve => require(['@/views/system/Module'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/system/Role',
      name: '角色管理',
      component: resolve => require(['@/views/system/Role'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/system/Dept',
      name: '公司管理',
      component: resolve => require(['@/views/system/Dept'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/system/Variable',
      name: '系统环境变量',
      component: resolve => require(['@/views/system/Variable'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/system/Permission',
      name: '权限管理',
      component: resolve => require(['@/views/system/Permission'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/machine/MachineConfig',
      name: '支付配置信息',
      component: resolve => require(['@/views/machine/MachineConfig'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/pay/Config',
      name: '支付配置',
      component: resolve => require(['@/views/pay/Config'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/druid/login',
      name: '监控查询',
      component: resolve => require(['@/views/druid/login'], resolve),
      meta: {
        requireAuth: true
      }
    }, {
      path: '/charts/statistics',
      name: '数据可视化',
      component: resolve => require(['@/views/charts/statistics'], resolve), // 首页
      meta: {
        requireAuth: true
      }
    }]
  }]
})
